<script type="text/javascript">
    var array = [];
    $(document).ready(function() {

        function validate_input(attname, attinput, atterror) {
            if (!attname) {
                $(attinput).attr('class', "inp-form-error");
                $(atterror).attr('style', 'visibility:visible');
                array.push(false);
            } else {
                $(attinput).attr('class', "inp-form");
                $(atterror).attr('style', 'visibility:hidden');
                array.push(true);
            }
        }

        function validate_textarea(attname, attinput, atterror) {
            if (!attname) {
                $(attinput).attr('class', "form-textarea-error");
                $(atterror).attr('style', 'visibility:visible');
                array.push(false);
            } else {
                $(attinput).attr('class', "form-textarea");
                $(atterror).attr('style', 'visibility:hidden');
                array.push(true);
            }
        }

        function validate_dropdown(attname, atterror) {
            if (attname == null) {
                $(atterror).attr('style', 'visibility:visible');
                array.push(false);
            } else {
                $(atterror).attr('style', 'visibility:hidden');
                array.push(true);
            }
        }

        $("input[name='submit']").click(function() {

            var name = $("input[id='videoName']").val();
//            var course = $("select[name='course']").val();
            var detail = $("textarea[name='videoDetail']").val();
//            var courseValue = course.options[course.selectedIndex].value;

            array.length = 0;
            
//            validate_dropdown(course, "div[id='error_course']");
            validate_input(name, "input[id='videoName']", "div[id='error_videoname']");
            validate_textarea(detail, "input[id='videoDetail']", "div[id='error_detail']");
//            validate_input(select, "", "div[id='error_newsselect']");

            for (var i in array) {
                if (!array[i]) {
                    return false;
                    break;
                }
            }
        });

    });
</script>

<div id="content-outer">
    <div id="content">


        <div id="page-heading"><h1><?php echo $main_title;?></h1></div>


        <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
            <tbody>
                <tr>
                    <th rowspan="3" class="sized"><img src="<?php echo base_url(); ?>images/shared/side_shadowleft.jpg" width="20" height="300" alt=""></th>
                    <th class="topleft"></th>
                    <td id="tbl-border-top">&nbsp;</td>
                    <th class="topright"></th>
                    <th rowspan="3" class="sized"><img src="<?php echo base_url(); ?>images/shared/side_shadowright.jpg" width="20" height="300" alt=""></th>
                </tr>
                <tr>
                    <td id="tbl-border-left"></td>
                    <td>
                        <!--  start content-table-inner -->
                        <div id="content-table-inner">

                            <table border="0" width="100%" cellpadding="0" cellspacing="0">
                                <tbody><tr valign="top">
                                        <td>


                                            <!--  start step-holder -->
                                            <!--<div id="step-holder">-->
                                            <!--                    <div class="step-no">1</div>
                                                                <div class="step-dark-left"><a href="">Information</a></div>
                                                                <div class="step-dark-right">&nbsp;</div>
                                                                <div class="step-no-off">2</div>
                                                                <div class="step-light-left">Select Courses</div>
                                                                <div class="step-light-round">&nbsp;</div>
                                                                <div class="clear"></div>-->
                                            <!--</div>-->
                                            <!--  end step-holder -->

                                            <!-- start id-form -->
                                            <?php // echo form_open_multipart('AddVideo/UploadVideo'); ?>
                                            <?php echo form_open('AddVideo/UploadVideo'); ?>
                                            <table border="0" cellpadding="0" cellspacing="0" id="id-form">
                                                <tbody>
                                                    <tr>
                                                        <th valign="top">Course:</th>
                                                        <td><?php echo form_dropdown('course', $courseList, $video['course'], 'class="styledselect-course"'); ?></td>
                                                        <td>
                                                            <div id="error_course" style="visibility: hidden">
                                                                <div class="error-left"></div>
                                                                <div class="error-inner">This field is required.</div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th valign="top">Video Type:</th>
                                                        <td><?php echo form_dropdown('type', $videoTypeList, $video['video_type'], 'class="styledselect-course"'); ?></td>
                                                        <td>
                                                            <div id="error_videotype" style="visibility: hidden">
                                                                <div class="error-left"></div>
                                                                <div class="error-inner">This field is required.</div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th valign="top">Video Name:</th>
                                                        <td><?php echo form_input($videoName, $video['video_name'], 'class="inp-form"'); ?></td>
                                                        <td>
                                                            <div id="error_videoname" style="visibility: hidden">
                                                                <div class="error-left"></div>
                                                                <div class="error-inner">This field is required.</div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <!--<?php if ($action != 'view') { ?>
                                                        <tr>
                                                            <th valign="top">Select Video:</th>
                                                            <td><?php echo form_upload('upload'); ?></td>
                                                            <td>
                                                                <div id="error_videoselect" style="visibility: hidden">
                                                                    <div class="error-left"></div>
                                                                    <div class="error-inner">This field is required.</div>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    <?php } ?> -->
                                                    <tr>
                                                        <th valign="top">Detail:</th>
                                                        <td><?php echo form_textarea($videoDetail, $video['video_detail'], 'class="form-textarea"'); ?></td>
                                                        <td>
                                                            <div id="error_detail" style="visibility: hidden">
                                                                <div class="error-left"></div>
                                                                <div class="error-inner">This field is required.</div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>&nbsp;</th>
                                                        <td valign="top">
                                                            <?php if ($action != 'view') : ?>
                                                                <?php echo form_submit('submit', 'Submit', 'class="form-submit"'); ?>
                                                                <?php echo form_reset('reset', 'Reset', 'class="form-reset"'); ?>
                                                            <?php else:?>
                                                                <?php echo anchor( base_url().'index.php/ViewVideo', '<img src="'.base_url().'images/forms/form_back.gif" alt="Back" />' ) ;?>
                                                            <?php endif;?>
                                                        </td>
                                                        <td></td>
                                                    </tr>
                                                </tbody></table>
                                            <?php echo form_close(); ?>
                                            <!-- end id-form  -->

                                        </td>
                                        <td>



                                        </td>
                                    </tr>
                                    <tr>
                                        <td><img src="images/shared/blank.gif" width="695" height="1" alt="blank"></td>
                                        <td></td>
                                    </tr>
                                </tbody></table>

                            <div class="clear"></div>


                        </div>
                        <!--  end content-table-inner  -->
                    </td>
                    <td id="tbl-border-right"></td>
                </tr>
                <tr>
                    <th class="sized bottomleft"></th>
                    <td id="tbl-border-bottom">&nbsp;</td>
                    <th class="sized bottomright"></th>
                </tr>
            </tbody></table>

        <div class="clear">&nbsp;</div>

    </div>
</div>